package com.tianlaiedu.service.impl;

import com.tianlaiedu.bean.Comment;
import com.tianlaiedu.dao.CommentMapper;
import com.tianlaiedu.dao.UserMapper;
import com.tianlaiedu.service.CommentService;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

/**
 * @author:hejing
 * @date:2021/12/3
 */
public class CommentServiceImpl implements CommentService {
    @Override
    public int addCom(Comment comment) {
        try(SqlSession sqlSession = com.tianlaiedu.utils.MapperUtil.getSqlSessionFactory().openSession(true)) {
            final CommentMapper commentMapper = sqlSession.getMapper(CommentMapper.class);
            return commentMapper.addCom(comment);
        }
    }

    @Override
    public int delCom(int id) {
        return 0;
    }

    @Override
    public List<Comment> finCom(int id) {
        try(SqlSession sqlSession = com.tianlaiedu.utils.MapperUtil.getSqlSessionFactory().openSession(true)) {
            final CommentMapper commentMapper = sqlSession.getMapper(CommentMapper.class);
            return commentMapper.finCom(id);
        }
    }

    @Override
    public List<Comment> fin2Com(int id) {
        return null;
    }
}
